 Imports MySql.Data.MySqlClient 
 Imports System.Data.OleDb
Imports System.Data.SqlClient
 Imports System .Data .SqlServerCe 
 Imports System.Data.OracleClient 
Imports System.Data
Imports DTO
Public Class PHIEUTHUDao
Inherits AbstractDao
 #Region "New" 
 Public Sub New(ByVal connection As KetNoiDto)
 MyBase.New(connection)
 End Sub
 Public Sub New( ByVal IDPHIEUTHU As System.Int32, ByVal connection As KetNoiDto)
 MyBase.New("PHIEUTHU", "select * from PHIEUTHU where IDPHIEUTHU=" & IDPHIEUTHU & "", connection)
 End Sub
 #End Region 
 Public Sub Them(ByVal Dto As PHIEUTHUDto)
 Dim strsql As String
 strsql = "Insert into PHIEUTHU(MAPHIEUTHU,IDHOCSINH,IDLOPHOC,NGAYBATDAU,TONGTIENPHAIDONG,TRANGTHAI,GHICHU) values (?,?,?,?,?,?,?)
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 Dim cmd As New OleDbCommand(strsql, Ket_noi_access)
cmd.Parameters.Add("@MAPHIEUTHU", OleDbType.Integer)
cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
cmd.Parameters.Add("@NGAYBATDAU", OleDbType.Date)
cmd.Parameters.Add("@TONGTIENPHAIDONG", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = Dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = Dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New OleDbCommand(strsql, Ket_noi_access)
 Dto.IDPHIEUTHU = cmd.ExecuteScalar()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress
 strsql = "Insert into PHIEUTHU(MAPHIEUTHU,IDHOCSINH,IDLOPHOC,NGAYBATDAU,TONGTIENPHAIDONG,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDHOCSINH,@IDLOPHOC,@NGAYBATDAU,@TONGTIENPHAIDONG,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlCommand(strsql, Ket_noi_sql)
cmd.Parameters.Add("@MAPHIEUTHU", SqlDbType.Int)
cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
cmd.Parameters.Add("@NGAYBATDAU", SqlDbType.DateTime)
cmd.Parameters.Add("@TONGTIENPHAIDONG", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = Dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = Dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New sqlCommand(strsql, Ket_noi_sql)
 Dto.IDPHIEUTHU = cmd.ExecuteScalar()
 Case Class_KieuDL.SqlCe
 strsql = "Insert into PHIEUTHU(MAPHIEUTHU,IDHOCSINH,IDLOPHOC,NGAYBATDAU,TONGTIENPHAIDONG,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDHOCSINH,@IDLOPHOC,@NGAYBATDAU,@TONGTIENPHAIDONG,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlceCommand(strsql, Ket_noi_SqlCe)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = Dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = Dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strsql = "Insert into PHIEUTHU(MAPHIEUTHU,IDHOCSINH,IDLOPHOC,NGAYBATDAU,TONGTIENPHAIDONG,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDHOCSINH,@IDLOPHOC,@NGAYBATDAU,@TONGTIENPHAIDONG,@TRANGTHAI,@GHICHU)
 Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = Dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = Dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Mysql
 strsql = "Insert into PHIEUTHU(MAPHIEUTHU,IDHOCSINH,IDLOPHOC,NGAYBATDAU,TONGTIENPHAIDONG,TRANGTHAI,GHICHU) values (@MAPHIEUTHU,@IDHOCSINH,@IDLOPHOC,@NGAYBATDAU,@TONGTIENPHAIDONG,@TRANGTHAI,@GHICHU)
 Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
cmd.Parameters.Add("@MAPHIEUTHU", MySqlDbType.Int32)
cmd.Parameters.Add("@IDHOCSINH", MySqlDbType.Int32)
cmd.Parameters.Add("@IDLOPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAYBATDAU",  MySqlDbType.DateTime)
cmd.Parameters.Add("@TONGTIENPHAIDONG", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters("@MAPHIEUTHU").Value = Dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = Dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = Dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub Xoa( ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
strSQL = "Delete From PHIEUTHU Where IDPHIEUTHU= ? 
Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDPHIEUTHU",OleDbType.Integer).Value = IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
strSQL = "Delete From PHIEUTHU Where IDPHIEUTHU= @IDPHIEUTHU
Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDPHIEUTHU",SqlDbType.Int).value=IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
strSQL = "Delete From PHIEUTHU Where IDPHIEUTHU=" & IDPHIEUTHU & "
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
strSQL = "Delete From PHIEUTHU Where IDPHIEUTHU=" & IDPHIEUTHU & "
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
strSQL = "Delete From PHIEUTHU Where IDPHIEUTHU=" & IDPHIEUTHU & "
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub sua(ByVal dto As PHIEUTHUDto)
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU=? ,IDHOCSINH=? ,IDLOPHOC=? ,NGAYBATDAU=? ,TONGTIENPHAIDONG=? ,TRANGTHAI=? ,GHICHU= ? where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@MAPHIEUTHU", OleDbType.Integer)
cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
cmd.Parameters.Add("@NGAYBATDAU", OleDbType.Date)
cmd.Parameters.Add("@TONGTIENPHAIDONG", OleDbType.Integer)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDHOCSINH= @IDHOCSINH , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , TONGTIENPHAIDONG= @TONGTIENPHAIDONG , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@MAPHIEUTHU", SqlDbType.Int)
cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
cmd.Parameters.Add("@NGAYBATDAU", SqlDbType.DateTime)
cmd.Parameters.Add("@TONGTIENPHAIDONG", SqlDbType.Int)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDHOCSINH= @IDHOCSINH , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , TONGTIENPHAIDONG= @TONGTIENPHAIDONG , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDHOCSINH= @IDHOCSINH , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , TONGTIENPHAIDONG= @TONGTIENPHAIDONG , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU= @MAPHIEUTHU , IDHOCSINH= @IDHOCSINH , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , TONGTIENPHAIDONG= @TONGTIENPHAIDONG , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
cmd.Parameters.Add("@MAPHIEUTHU", MySqlDbType.Int32)
cmd.Parameters.Add("@IDHOCSINH", MySqlDbType.Int32)
cmd.Parameters.Add("@IDLOPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAYBATDAU",  MySqlDbType.DateTime)
cmd.Parameters.Add("@TONGTIENPHAIDONG", MySqlDbType.Int32)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters.Add("@IDPHIEUTHU", MySqlDbType.Int32)
cmd.Parameters("@MAPHIEUTHU").Value = dto.MAPHIEUTHU
cmd.Parameters("@IDHOCSINH").Value = dto.IDHOCSINH
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@TONGTIENPHAIDONG").Value = dto.TONGTIENPHAIDONG
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDPHIEUTHU").Value = dto.IDPHIEUTHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub SuaMAPHIEUTHU( ByVal MAPHIEUTHU as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU = ?  where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@MAPHIEUTHU", OleDbType.Integer)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@MAPHIEUTHU").Value =  MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU = @MAPHIEUTHU  where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@MAPHIEUTHU", SqlDbType.Int)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@MAPHIEUTHU").Value =  MAPHIEUTHU
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU =" & MAPHIEUTHU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU =" & MAPHIEUTHU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set MAPHIEUTHU =" & MAPHIEUTHU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDHOCSINH( ByVal IDHOCSINH as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set IDHOCSINH = ?  where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDHOCSINH", OleDbType.Integer)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set IDHOCSINH = @IDHOCSINH  where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDHOCSINH", SqlDbType.Int)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@IDHOCSINH").Value =  IDHOCSINH
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set IDHOCSINH =" & IDHOCSINH & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set IDHOCSINH =" & IDHOCSINH & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set IDHOCSINH =" & IDHOCSINH & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDLOPHOC( ByVal IDLOPHOC as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set IDLOPHOC = ?  where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set IDLOPHOC = @IDLOPHOC  where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set IDLOPHOC =" & IDLOPHOC & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set IDLOPHOC =" & IDLOPHOC & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set IDLOPHOC =" & IDLOPHOC & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGAYBATDAU( ByVal NGAYBATDAU as System.DateTime, ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set NGAYBATDAU = ?  where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGAYBATDAU", OleDbType.Date)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@NGAYBATDAU").Value =  NGAYBATDAU
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set NGAYBATDAU = @NGAYBATDAU  where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGAYBATDAU", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@NGAYBATDAU").Value =  NGAYBATDAU
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set NGAYBATDAU =" & NGAYBATDAU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set NGAYBATDAU =" & NGAYBATDAU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set NGAYBATDAU =" & NGAYBATDAU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTONGTIENPHAIDONG( ByVal TONGTIENPHAIDONG as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set TONGTIENPHAIDONG = ?  where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TONGTIENPHAIDONG", OleDbType.Integer)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@TONGTIENPHAIDONG").Value =  TONGTIENPHAIDONG
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set TONGTIENPHAIDONG = @TONGTIENPHAIDONG  where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TONGTIENPHAIDONG", SqlDbType.Int)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@TONGTIENPHAIDONG").Value =  TONGTIENPHAIDONG
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set TONGTIENPHAIDONG =" & TONGTIENPHAIDONG & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set TONGTIENPHAIDONG =" & TONGTIENPHAIDONG & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set TONGTIENPHAIDONG =" & TONGTIENPHAIDONG & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set TRANGTHAI = ?  where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set TRANGTHAI = @TRANGTHAI  where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set TRANGTHAI =" & TRANGTHAI & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set TRANGTHAI =" & TRANGTHAI & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set TRANGTHAI =" & TRANGTHAI & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGHICHU( ByVal GHICHU as System.String, ByVal IDPHIEUTHU As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update PHIEUTHU Set GHICHU = ?  where IDPHIEUTHU= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDPHIEUTHU", OleDbType.Integer)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update PHIEUTHU Set GHICHU = @GHICHU  where IDPHIEUTHU= @IDPHIEUTHU"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDPHIEUTHU", SqlDbType.Int)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDPHIEUTHU").Value =  IDPHIEUTHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update PHIEUTHU Set GHICHU =" & GHICHU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update PHIEUTHU Set GHICHU =" & GHICHU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update PHIEUTHU Set GHICHU =" & GHICHU & "  where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub layBang()
 Chuoi_SQL = " Select * from PHIEUTHU
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDPHIEUTHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDPHIEUTHU=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDPHIEUTHU(ByVal IDPHIEUTHU As System.Int32 )
 Chuoi_SQL = " Select * from PHIEUTHU where  IDPHIEUTHU = " & IDPHIEUTHU & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDPHIEUTHU(ByVal IDPHIEUTHU As System.Int32)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where IDPHIEUTHU=" & IDPHIEUTHU & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoMAPHIEUTHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "MAPHIEUTHU=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoMAPHIEUTHU(ByVal MAPHIEUTHU As System.Int32 )
 Chuoi_SQL = " Select * from PHIEUTHU where  MAPHIEUTHU = " & MAPHIEUTHU & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoMAPHIEUTHU(ByVal MAPHIEUTHU As System.Int32)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where MAPHIEUTHU=" & MAPHIEUTHU & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDHOCSINH(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDHOCSINH=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDHOCSINH(ByVal IDHOCSINH As System.Int32 )
 Chuoi_SQL = " Select * from PHIEUTHU where  IDHOCSINH = " & IDHOCSINH & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDHOCSINH(ByVal IDHOCSINH As System.Int32)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where IDHOCSINH=" & IDHOCSINH & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDLOPHOC=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32 )
 Chuoi_SQL = " Select * from PHIEUTHU where  IDLOPHOC = " & IDLOPHOC & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where IDLOPHOC=" & IDLOPHOC & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGAYBATDAU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGAYBATDAU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGAYBATDAU(ByVal NGAYBATDAU As System.DateTime )
 Chuoi_SQL = " Select * from PHIEUTHU where  NGAYBATDAU = @Ngay
 Doc_bang_Dk_ngay(NGAYBATDAU)
 End Sub
 Public Sub layBangTheoNGAYBATDAU(ByVal NGAYBATDAU1 As System.DateTime,ByVal NGAYBATDAU2 As System.DateTime )
 Chuoi_SQL = " Select * from PHIEUTHU where  NGAYBATDAU >= @Ngay and NGAYBATDAU <= @denNgay ORDER BY NGAYBATDAU
 Doc_bang_Dk_ngay(NGAYBATDAU1,NGAYBATDAU2)
 End Sub
 Public Sub XOABangTheoNGAYBATDAU(ByVal NGAYBATDAU As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where NGAYBATDAU='" & NGAYBATDAU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTONGTIENPHAIDONG(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TONGTIENPHAIDONG=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTONGTIENPHAIDONG(ByVal TONGTIENPHAIDONG As System.Int32 )
 Chuoi_SQL = " Select * from PHIEUTHU where  TONGTIENPHAIDONG = " & TONGTIENPHAIDONG & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTONGTIENPHAIDONG(ByVal TONGTIENPHAIDONG As System.Int32)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where TONGTIENPHAIDONG=" & TONGTIENPHAIDONG & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TRANGTHAI=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32 )
 Chuoi_SQL = " Select * from PHIEUTHU where  TRANGTHAI = " & TRANGTHAI & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where TRANGTHAI=" & TRANGTHAI & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGHICHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "GHICHU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from PHIEUTHU" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU_like (ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from PHIEUTHU where  GHICHU  like '%" & GHICHU & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU(ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from PHIEUTHU where  GHICHU = '" & GHICHU & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGHICHU(ByVal GHICHU As System.String)
 Dim strsql As String
 strSQL = "Delete From PHIEUTHU Where GHICHU='" & GHICHU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangNhieuTable
 Chuoi_SQL = " Select IDPHIEUTHU ,MAPHIEUTHU ,IDHOCSINH ,IDLOPHOC ,NGAYBATDAU ,TONGTIENPHAIDONG ,TRANGTHAI ,GHICHU  from PHIEUTHU"
 Doc_bang()
 End sub
Public Sub TaoTable()
Dim strsql As String
strsql = ""
Select Case ketnoi.MsSql
Case Class_KieuDL.Access 
Case Class_KieuDL.Sql, Class_KieuDL.sqlExpress
strsql = ""
Case Class_KieuDL.SqlCe
strsql = ""
Case Class_KieuDL.Oracle
strsql = ""
Case else 
strsql = ""
End Select
Thuc_hien_lenh(strsql)
End Sub
 End Class

